using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Diagnostics;

public sealed class Progam {
   public static void Main() {
      TextWriter tw = new StringWriter();
      SomeType st = new SomeType(tw);

      // PrepareDelegate forces WriteBytes to be compiled now
		RuntimeHelpers.PrepareDelegate(new M(st.WriteBytes));

      // Launch the debugger now so I can step into WriteBytes and
      // capture the native code via the Disassembly window.
      // NOTE: Launching the debugger after compiling the code 
      // causes optimized code to be generated
		Debugger.Launch();

      st.WriteBytes(new Byte[] { 1, 2, 3 });
   }

   private delegate void M(Byte[] l);
}


internal sealed class SomeType {
   private TextWriter m_textWriter;

   public SomeType(TextWriter tw) {
      m_textWriter = tw;
   }

   public void WriteBytes(Byte[] bytes) {
      for (Int32 x = 0; x < bytes.Length; x++) {
         m_textWriter.Write(bytes[x]);
      }
   }
}
